﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IFRS.Web;
using System.Data;
using IFRS.DataAccess.DAL;
using IFRS.Models;
using IFRS_Global;
using vsm.CustomControl;

public partial class IFRS_WIN31_GL_LN_3V : PageBase
{
    #region "---------- Property -----------"

    #endregion

    #region "---------- Events -----------"

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Page.IsPostBack || Page.IsCallback))
        {
            this.ViewMenu();
            BindControlData();
            SetErrorMessage();
            BindData();

            if (Request.QueryString["GroupID"] != null)
            {
                hidGLGroup_ID.Value = Request.QueryString["GroupID"].ToString();
                txtGLGroup.Text = Request.QueryString["GroupName"].ToString();
            }
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }

    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN31_1S.aspx");
    }

    #endregion

    #region "---------- Methods -----------"

    private void ViewMenu()
    {
        this.MenuTitleBar = Resources.ifrsResource.View + Resources.ifrsMenu.WIN04;
    }

    private void SetErrorMessage()
    {
    }

    private void BindControlData()
    {
        SetControlReadOnly(form_control);
    }

    private void BindData()
    {
        if (Request.QueryString["id"] == null)
            return;

        int ID = Convert.ToInt32(Request.QueryString["id"].ToString());
        List<GLAccountPosting> glAccountPosting = new List<GLAccountPosting>();
        DataTable dt = new SPR_GLACCOUNTPOSTING().SEARCH_BYID(ID);
        if (dt.Rows.Count > 0)
        {
            ConvertHelper.ConvertDataTableToObject(dt, glAccountPosting);
            txtGLAccount.Text = glAccountPosting[0].GLAccount_CODE;
            txtGL_ADJ_INT_INC_PL.Text = glAccountPosting[0].GL_ADJ_INT_INC_PL_CODE;
            txtGL_ADJ_FV_BS.Text = glAccountPosting[0].GL_ADJ_FV_BS_CODE;
            txtGL_ADJ_INT_INC_ELCLS_PL.Text = glAccountPosting[0].GL_ADJ_INT_INC_ELCLS_PL_CODE;
            txtGL_ADJ_CST_BS.Text = glAccountPosting[0].GL_ADJ_CST_BS_CODE;
            txtGL_REV_CST_PL.Text = glAccountPosting[0].GL_REV_CST_PL_CODE;
            txtGL_ADJ_FEE_BS.Text = glAccountPosting[0].GL_ADJ_FEE_BS_CODE;
            txtGL_REV_FEE_PL.Text = glAccountPosting[0].GL_REV_FEE_PL_CODE;
            txtGL_SUBSEQ_ADJ_CST_BS.Text = glAccountPosting[0].GL_SUBSEQ_ADJ_CST_BS_CODE;
            txtGL_SUBSEQ_ADJ_FEE_BS.Text = glAccountPosting[0].GL_SUBSEQ_ADJ_FEE_BS_CODE;
            txtGL_IMP_LOSS_PL.Text = glAccountPosting[0].GL_IMP_LOSS_PL_CODE;
            txtGL_ALLW_BAD_DEBT_PL.Text = glAccountPosting[0].GL_ALLW_BAD_DEBT_PL_CODE;
            txtGL_WOFF_ADJ_FV_BS.Text = glAccountPosting[0].GL_WOFF_ADJ_FV_BS_CODE;
            txtGL_WOFF_ADJ_FEE_BS.Text = glAccountPosting[0].GL_WOFF_ADJ_FEE_BS_CODE;
            txtGL_WOFF_ADJ_CST_BS.Text = glAccountPosting[0].GL_WOFF_ADJ_CST_BS_CODE;
            txtGL_DAY1_FV_LOSS_PL.Text = glAccountPosting[0].GL_DAY1_FV_LOSS_PL_CODE;
            txtGL_DAY1_ADJ_FV_BS.Text = glAccountPosting[0].GL_DAY1_ADJ_FV_BS_CODE;
            txtGL_WOFF_INT_DISC_LN.Text = glAccountPosting[0].GL_WOFF_INT_DISC_LN_CODE;
            txtGL_DAY1_DEF_EXP_STAFF_BS.Text = glAccountPosting[0].GL_DAY1_DEF_EXP_STAFF_BS_CODE;
            txtGL_AMC_EMP_CST_PL.Text = glAccountPosting[0].GL_AMC_EMP_CST_PL_CODE;
            txtGL_AMC_DEF_EXP_STAFF_BS.Text = glAccountPosting[0].GL_AMC_DEF_EXP_STAFF_BS_CODE;
            txtGL_SUBSIDY_INT_REC_BS.Text = glAccountPosting[0].GL_SUBSIDY_INT_REC_BS_CODE;
            txtGL_SUBSIDY_INT_INC_PL.Text = glAccountPosting[0].GL_SUBSIDY_INT_INC_PL_CODE;


            txtGLGroup.Text = glAccountPosting[0].GLGroup_NAME;
            txtGLAccount_NAME.Text = glAccountPosting[0].GLAccount_NAME;
            txtGL_ADJ_INT_INC_PL_NAME.Text = glAccountPosting[0].GL_ADJ_INT_INC_PL_NAME;
            txtGL_ADJ_FV_BS_NAME.Text = glAccountPosting[0].GL_ADJ_FV_BS_NAME;
            txtGL_ADJ_INT_INC_ELCLS_PL_NAME.Text = glAccountPosting[0].GL_ADJ_INT_INC_ELCLS_PL_NAME;
            txtGL_ADJ_CST_BS_NAME.Text = glAccountPosting[0].GL_ADJ_CST_BS_NAME;
            txtGL_REV_CST_PL_NAME.Text = glAccountPosting[0].GL_REV_CST_PL_NAME;
            txtGL_ADJ_FEE_BS_NAME.Text = glAccountPosting[0].GL_ADJ_FEE_BS_NAME;
            txtGL_REV_FEE_PL_NAME.Text = glAccountPosting[0].GL_REV_FEE_PL_NAME;
            txtGL_SUBSEQ_ADJ_CST_BS_NAME.Text = glAccountPosting[0].GL_SUBSEQ_ADJ_CST_BS_NAME;
            txtGL_SUBSEQ_ADJ_FEE_BS_NAME.Text = glAccountPosting[0].GL_SUBSEQ_ADJ_FEE_BS_NAME;
            txtGL_IMP_LOSS_PL_NAME.Text = glAccountPosting[0].GL_IMP_LOSS_PL_NAME;
            txtGL_ALLW_BAD_DEBT_PL_NAME.Text = glAccountPosting[0].GL_ALLW_BAD_DEBT_PL_NAME;
            txtGL_WOFF_ADJ_FV_BS_NAME.Text = glAccountPosting[0].GL_WOFF_ADJ_FV_BS_NAME;
            txtGL_WOFF_ADJ_FEE_BS_NAME.Text = glAccountPosting[0].GL_WOFF_ADJ_FEE_BS_NAME;
            txtGL_WOFF_ADJ_CST_BS_NAME.Text = glAccountPosting[0].GL_WOFF_ADJ_CST_BS_NAME;
            txtGL_DAY1_FV_LOSS_PL_NAME.Text = glAccountPosting[0].GL_DAY1_FV_LOSS_PL_NAME;
            txtGL_DAY1_ADJ_FV_BS_NAME.Text = glAccountPosting[0].GL_DAY1_ADJ_FV_BS_NAME;
            txtGL_WOFF_INT_DISC_LN_NAME.Text = glAccountPosting[0].GL_WOFF_INT_DISC_LN_NAME;
            txtGL_DAY1_DEF_EXP_STAFF_BS_NAME.Text = glAccountPosting[0].GL_DAY1_DEF_EXP_STAFF_BS_NAME;
            txtGL_AMC_EMP_CST_PL_NAME.Text = glAccountPosting[0].GL_AMC_EMP_CST_PL_NAME;
            txtGL_AMC_DEF_EXP_STAFF_BS_NAME.Text = glAccountPosting[0].GL_AMC_DEF_EXP_STAFF_BS_NAME;
            txtGL_SUBSIDY_INT_REC_BS_NAME.Text = glAccountPosting[0].GL_SUBSIDY_INT_REC_BS_NAME;
            txtGL_SUBSIDY_INT_INC_PL_NAME.Text = glAccountPosting[0].GL_SUBSIDY_INT_INC_PL_NAME;

            hidGLAccountPostingID.Value = glAccountPosting[0].GLAccountPostingID.IntToString();
            hidGLGroup_ID.Value = glAccountPosting[0].GLGroupID.IntToString();
            hidGLAccount.Value = glAccountPosting[0].GLAccountID.IntToString();
            hidGL_ADJ_INT_INC_PL.Value = glAccountPosting[0].GL_ADJ_INT_INC_PL_ID.IntToString();
            hidGL_ADJ_FV_BS.Value = glAccountPosting[0].GL_ADJ_FV_BS_ID.IntToString();
            hidGL_ADJ_INT_INC_ELCLS_PL.Value = glAccountPosting[0].GL_ADJ_INT_INC_ELCLS_PL_ID.IntToString();
            hidGL_ADJ_CST_BS.Value = glAccountPosting[0].GL_ADJ_CST_BS_ID.IntToString();
            hidGL_REV_CST_PL.Value = glAccountPosting[0].GL_REV_CST_PL_ID.IntToString();
            hidGL_ADJ_FEE_BS.Value = glAccountPosting[0].GL_ADJ_FEE_BS_ID.IntToString();
            hidGL_REV_FEE_PL.Value = glAccountPosting[0].GL_REV_FEE_PL_ID.IntToString();
            hidGL_SUBSEQ_ADJ_CST_BS.Value = glAccountPosting[0].GL_SUBSEQ_ADJ_CST_BS_ID.IntToString();
            hidGL_SUBSEQ_ADJ_FEE_BS.Value = glAccountPosting[0].GL_SUBSEQ_ADJ_FEE_BS_ID.IntToString();
            hidGL_IMP_LOSS_PL.Value = glAccountPosting[0].GL_IMP_LOSS_PL_ID.IntToString();
            hidGL_ALLW_BAD_DEBT_PL.Value = glAccountPosting[0].GL_ALLW_BAD_DEBT_PL_ID.IntToString();
            hidGL_WOFF_ADJ_FV_BS.Value = glAccountPosting[0].GL_WOFF_ADJ_FV_BS_ID.IntToString();
            hidGL_WOFF_ADJ_FEE_BS.Value = glAccountPosting[0].GL_WOFF_ADJ_FEE_BS_ID.IntToString();
            hidGL_WOFF_ADJ_CST_BS.Value = glAccountPosting[0].GL_WOFF_ADJ_CST_BS_ID.IntToString();
            hidGL_DAY1_FV_LOSS_PL.Value = glAccountPosting[0].GL_DAY1_FV_LOSS_PL_ID.IntToString();
            hidGL_DAY1_ADJ_FV_BS.Value = glAccountPosting[0].GL_DAY1_ADJ_FV_BS_ID.IntToString();
            hidGL_WOFF_INT_DISC_LN.Value = glAccountPosting[0].GL_WOFF_INT_DISC_LN_ID.IntToString();
            hidGL_DAY1_DEF_EXP_STAFF_BS.Value = glAccountPosting[0].GL_DAY1_DEF_EXP_STAFF_BS_ID.IntToString();
            hidGL_AMC_EMP_CST_PL.Value = glAccountPosting[0].GL_AMC_EMP_CST_PL_ID.IntToString();
            hidGL_AMC_DEF_EXP_STAFF_BS.Value = glAccountPosting[0].GL_AMC_DEF_EXP_STAFF_BS_ID.IntToString();
            hidGL_SUBSIDY_INT_REC_BS.Value = glAccountPosting[0].GL_SUBSIDY_INT_REC_BS_ID.IntToString();
            hidGL_SUBSIDY_INT_INC_PL.Value = glAccountPosting[0].GL_SUBSIDY_INT_INC_PL_ID.IntToString();
        }
    }

    #endregion
}